<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Requests\SignRequest;
use App\Http\Requests\UserContext;
use App\Http\Services\OrderService;
use App\Http\Services\TaskService;
use App\Http\Services\TeamService;
use App\Http\Traits\ResponseJson;

class TaskController extends Controller
{
    use ResponseJson;

    protected $taskService;

    public function __construct(TaskService $taskService)
    {
        $this->taskService = $taskService;
    }

    public function lists()
    {
        $data = $this->taskService->lists();
        return $this->returnJson($data);
    }

    /**
     * 扫街添加,编辑
     * @param UserContext $userContext
     * @param SignRequest $signRequest
     * @return \Illuminate\Http\JsonResponse
     * @throws \App\Exceptions\ServiceException
     */
    public function sweepAdd(UserContext $userContext, SignRequest $signRequest)
    {
        $data = $this->taskService->sweepAdd($userContext, $signRequest);
        return $this->returnJson($data);
    }

    /**
     * 入户调研获取
     * @param UserContext $userContext
     * @return \Illuminate\Http\JsonResponse
     * @throws \App\Exceptions\ServiceException
     */
    public function entrySurveyGet(UserContext $userContext)
    {
        $data = $this->taskService->entrySurveyGet($userContext);
        return $this->returnJson($data);
    }

    /**
     * 入户调研保存
     * @param UserContext $userContext
     * @return \Illuminate\Http\JsonResponse
     * @throws \App\Exceptions\ServiceException
     */
    public function entrySurveySave(UserContext $userContext)
    {
        $data = $this->taskService->entrySurveySave($userContext);
        return $this->returnJson($data);
    }

    /**
     * 队伍标记
     * @return \Illuminate\Http\JsonResponse
     */
    public function teamSign()
    {
        $data = $this->taskService->teamSign();
        return $this->returnJson($data);
    }

    /**
     * 标记详情
     * @param UserContext $userContext
     * @return \Illuminate\Http\JsonResponse
     * @throws \App\Exceptions\ServiceException
     */
    public function signDetail(UserContext $userContext)
    {
        $data = $this->taskService->signDetail($userContext);
        return $this->returnJson($data);
    }

    /**
     * 删除扫街
     * @param UserContext $userContext
     * @return \Illuminate\Http\JsonResponse
     */
    public function sweepDelete(UserContext $userContext)
    {
        $data = $this->taskService->sweepDelete($userContext);
        return $this->returnJson($data);
    }

    /**
     * 队伍队员位置
     * @param UserContext $userContext
     * @return \Illuminate\Http\JsonResponse
     * @throws \App\Exceptions\ServiceException
     */
    public function teamPos(UserContext $userContext)
    {
        $data = $this->taskService->teamPos($userContext);
        return $this->returnJson($data);
    }

}
